<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Linux容器 Web终端</title>
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/xterm@5.3.0/css/xterm.css">
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }

        body {
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            height: 100vh;
            display: flex;
            flex-direction: column;
        }

        .header {
            background: rgba(255, 255, 255, 0.1);
            backdrop-filter: blur(10px);
            padding: 20px;
            text-align: center;
            color: white;
            box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
        }

        .header h1 {
            font-size: 2rem;
            margin-bottom: 10px;
            text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
        }

        .connection-info {
            display: flex;
            justify-content: center;
            gap: 20px;
            margin-bottom: 15px;
            flex-wrap: wrap;
        }

        .info-item {
            background: rgba(255, 255, 255, 0.2);
            padding: 8px 15px;
            border-radius: 20px;
            font-size: 0.9rem;
        }

        .controls {
            display: flex;
            justify-content: center;
            gap: 15px;
            flex-wrap: wrap;
        }

        .btn {
            padding: 10px 20px;
            border: none;
            border-radius: 25px;
            cursor: pointer;
            font-size: 0.9rem;
            font-weight: 600;
            transition: all 0.3s ease;
            text-transform: uppercase;
            letter-spacing: 1px;
        }

        .btn-connect {
            background: #4CAF50;
            color: white;
        }

        .btn-connect:hover {
            background: #45a049;
            transform: translateY(-2px);
            box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
        }

        .btn-disconnect {
            background: #f44336;
            color: white;
        }

        .btn-disconnect:hover {
            background: #da190b;
            transform: translateY(-2px);
            box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
        }

        .btn-clear {
            background: #2196F3;
            color: white;
        }

        .btn-clear:hover {
            background: #1976D2;
            transform: translateY(-2px);
            box-shadow: 0 4px 8px rgba(0, 0, 0, 0.2);
        }

        .terminal-container {
            flex: 1;
            padding: 20px;
            display: flex;
            justify-content: center;
            align-items: center;
        }

        .terminal-wrapper {
            background: #1e1e1e;
            border-radius: 10px;
            padding: 20px;
            box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
            width: 100%;
            max-width: 1200px;
            height: 70vh;
            position: relative;
            overflow: hidden;
        }

        .terminal-header {
            display: flex;
            align-items: center;
            margin-bottom: 15px;
            padding-bottom: 10px;
            border-bottom: 1px solid #333;
        }

        .terminal-dots {
            display: flex;
            gap: 8px;
            margin-right: 15px;
        }

        .dot {
            width: 12px;
            height: 12px;
            border-radius: 50%;
        }

        .dot.red { background: #ff5f56; }
        .dot.yellow { background: #ffbd2e; }
        .dot.green { background: #27ca3f; }

        .terminal-title {
            color: #ccc;
            font-size: 0.9rem;
            font-weight: 500;
        }

        .status {
            position: absolute;
            top: 15px;
            right: 20px;
            padding: 5px 12px;
            border-radius: 15px;
            font-size: 0.8rem;
            font-weight: 600;
            text-transform: uppercase;
        }

        .status.connected {
            background: #4CAF50;
            color: white;
        }

        .status.disconnected {
            background: #f44336;
            color: white;
        }

        .status.connecting {
            background: #ff9800;
            color: white;
        }

        #terminal {
            height: calc(100% - 60px);
            width: 100%;
        }

        .loading {
            display: none;
            text-align: center;
            color: #ccc;
            font-size: 1.1rem;
            margin-top: 50px;
        }

        .loading.show {
            display: block;
        }

        @keyframes pulse {
            0%, 100% { opacity: 1; }
            50% { opacity: 0.5; }
        }

        .loading {
            animation: pulse 1.5s infinite;
        }

        @media (max-width: 768px) {
            .header {
                padding: 15px;
            }

            .header h1 {
                font-size: 1.5rem;
            }

            .connection-info {
                flex-direction: column;
                gap: 10px;
            }

            .controls {
                flex-direction: column;
                gap: 10px;
            }

            .btn {
                width: 100%;
                max-width: 200px;
            }

            .terminal-container {
                padding: 10px;
            }

            .terminal-wrapper {
                height: 60vh;
                padding: 15px;
            }
        }
    </style>
</head>
<body>
    <div class="header">
        <h1>🐧 Linux容器 Web终端</h1>
        <div class="connection-info">
            <div class="info-item">📡 主机: localhost:2222</div>
            <div class="info-item">👤 用户: developer</div>
            <div class="info-item">🔑 密码: dev123</div>
        </div>
        <div class="controls">
            <button class="btn btn-connect" onclick="connectSSH()">🔗 连接SSH</button>
            <button class="btn btn-disconnect" onclick="disconnect()">❌ 断开连接</button>
            <button class="btn btn-clear" onclick="clearTerminal()">🧹 清屏</button>
        </div>
    </div>

    <div class="terminal-container">
        <div class="terminal-wrapper">
            <div class="terminal-header">
                <div class="terminal-dots">
                    <div class="dot red"></div>
                    <div class="dot yellow"></div>
                    <div class="dot green"></div>
                </div>
                <div class="terminal-title">developer@linux-basic:~</div>
                <div class="status disconnected" id="status">未连接</div>
            </div>
            <div id="terminal"></div>
            <div class="loading" id="loading">
                🔄 正在连接到Linux容器...
            </div>
        </div>
    </div>

    <script src="https://cdn.jsdelivr.net/npm/xterm@5.3.0/lib/xterm.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/xterm-addon-fit@0.8.0/lib/xterm-addon-fit.js"></script>
    <script src="https://cdn.jsdelivr.net/npm/xterm-addon-web-links@0.9.0/lib/xterm-addon-web-links.js"></script>
    <script src="app.js"></script>
</body>
</html>